<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

</head>

<body>
    <button type="button" id="blob">压缩</button>
    <input type="text" id="demo">
    <script src="jszip.min.js"></script>
    <script>
        var zip = new JSZip();
        document.querySelector("#blob").addEventListener("click", function () {
            zip.file("Hello.blob", document.querySelector("#demo").value);
            zip.generateAsync({ type: "base64" }).then(function (base64) { // 1) generate the zip file
                window.location = "data:application/zip;base64," + base64;                       // 2) trigger the download
            }, function (err) {
                document.querySelector("#blob").text = err;
            });
        });
    </script>
</body>

</html>